πΎ Database Request
The Database Request feature enables you to query data from your AppStruct Backend and map that data to components on your screen. This is particularly useful for displaying dynamic content from tables directly in your app.
Before You Beginβ
For a smooth experience, make sure you have already set up your AppStruct Backend and created your necessary tables. For more details on creating a backend, please refer to the AppStruct Backend documentation.
How to Useβ
- Drag a card component (or any container element) onto your canvas where you want to display the data.
- Select the card component you added and click Add Action in the left bar.
- A special node for the Database Request action will appear. Click on it node to open its settings panel.
- Map the Request Settings:
- Action Trigger:
- Choose when the request should run. For a simple example, select on page load.
- Backend Platform:
- Choose AppStruct Backend as your data source.
- Table Selection:
- Select the table from which you want to fetch data (e.g., Cars).
- Method:
- Choose Select to retrieve data from the table. You can also have: Insert, Update, Delete.
- Action Trigger:
Adding Filtersβ
If you need to narrow down the data returned by your query:
- Click Add Filters.
- Set the filter criteria by choosing the column, the comparison operator (e.g., =), and the value. You can add multiple filters if needed.
Connecting Dataβ
- Click Connect to component in the Database Request settings.
- Choose the column from your table that you want to display (e.g., the Name column from the Cars table).
- Map this data to the corresponding element within your card component (e.g., the Π‘ard Title element).
- In the component settings, select the type (in our example, itβs Text) to ensure proper data display.
Previewβ
- Once you have mapped all columns from your table to the corresponding UI components (e.g., title, subtitle, image) in your card, itβs time to see the results.
- At the top-right corner of the editor, click Preview to open a live view of your app.
- Ensure that the data from your selected table columns (e.g., βFerrariβ for Name, β100,000$β for Price, etc.) is correctly displayed in each mapped component.
- If your app has interactive elements (e.g., filters, buttons), test them to confirm they function correctly with the database request.
Best Practicesβ
- Plan Your Data Structure: Organize your backend tables and columns carefully before integrating with your UI. A well-planned structure simplifies mapping and ensures scalability.
- Use Filters Wisely: Apply filters to limit the data retrieved to only whatβs necessary. This reduces load times and improves performance, especially with large datasets.
- Consistent Naming Conventions: Use clear, consistent names for your tables and columns. This makes mapping easier and reduces errors when connecting data to UI components.
- Test Thoroughly: Regularly use the preview mode to verify that data is loaded correctly and UI components display the expected values. Test various scenarios, including edge cases where no data is returned.
- Optimize Data Requests: When possible, minimize the amount of data fetched by selecting only the required columns. This ensures faster load times and a smoother user experience.
- Iterative Development: Start with simple requests and mappings. Once the basic functionality works, gradually add filters and additional data fields to refine your appβs functionality.
Need Assistance?β
If you encounter any challenges or require further guidance while building your app, please refer to the Documentation or, contact our support team at [email protected].